/********************************************************************
        created:        2010/02/21
        filename:       htl_epoll.h
        author:         HongLiang

        purpose:   	epoll
*********************************************************************/
#ifndef __HTL_EPOLL_H__
#define __HTL_EPOLL_H__
#include "../container/htl_config.h"
#include "../container/htl_vector.h"
#include <sys/epoll.h>
__HTL_BEGIN_NAMESPACE
class epoll_aux : public ioevent {
/*public:
	typedef void (*call_hander)(epoll_aux* pbase, int fd, int events);*/
public:
	epoll_aux() : epoll_fd(-1), maxfds(-1), epoll_events(0) {}
	virtual ~epoll_aux() {}
	HTL_RESULT event_init(int _maxfds = 1024);
	HTL_RESULT event_add(int fd, int events);
	HTL_RESULT event_mod(int fd, int events);
	HTL_RESULT event_del(int fd);
	HTL_RESULT event_register(int fd, call_handler handler);
	HTL_RESULT event_unregister(int fd);
	HTL_RESULT event_poll(void* args, int timeout_ms);
protected:
	int epoll_fd;
	int maxfds;
	/*epoll_event* epoll_events;
	call_hander* sequence_hander;*/
	htl::vector<epoll_event> epoll_events;
	htl::vector<call_handler> sequence_handler;
};

__HTL_END_NAMESPACE
#endif
